﻿using Microsoft.SharePoint.Client;
using System;

namespace IteraProvisioning.Core
{
    /// <summary>
    /// Class that deals with feature activation and deactivation
    /// </summary>
    public static class FeatureExtensions
    {
        public static bool ActivateDisabledFeature(this Web web, Guid guid)
        {
            bool active = false;
            if (!web.IsFeatureActive(guid))
            {
                web.ActivateFeature(guid);
                active = true;
            }
            return active;
        }

        public static bool ActivateDisabledFeature(this Site site, Guid guid)
        {
            bool active = false;
            if (!site.IsFeatureActive(guid))
            {
                site.ActivateFeature(guid);
                active = true;
            }
            return active;
        }
    }
}
